package com.linzm.structuraltype.adapter01.factory;

import com.linzm.structuraltype.adapter01.mediaplayer.AdvancedMediaPlayer;
import com.linzm.structuraltype.adapter01.enums.MediaTypeEnum;

/**
 * @Author zimingl
 * @Date 2023/4/15 21:59
 * @Description: MediaPlayerFactory
 */
public class MediaPlayerFactory {
    public AdvancedMediaPlayer getAdvancedMediaPlayer(String type) throws Exception {
        MediaTypeEnum mediaTypeEnum = MediaTypeEnum.valueOf(type);
        Class<?> clazz = mediaTypeEnum.getClazz();
        return (AdvancedMediaPlayer) clazz.newInstance();
    }
}
